package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionToArray {
    public static void main(String[] args) {
        //集合转换成数组
        Collection<String> coll=new ArrayList<>();
        coll.add("one");
        coll.add("two");
        coll.add("three");
        coll.add("four");
        coll.add("five");
        System.out.println(coll);
        //集合转数组
        String[] arr=coll.toArray(new String[coll.size()]);
        System.out.println(Arrays.toString(arr));
        String[] arr1=coll.toArray(new String[8]);
        System.out.println(Arrays.toString(arr1));
        //如果输入的长度




    }
}
